<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/layui/layui.all.js}"></script>
</head>
<body>

<table class="layui-table" id="table">

</table>

<script>
    var oldUrl = window.location.href;
    var newUrl = oldUrl.replace("chapter", "chapterList");
    $(function () {
        $.get(newUrl, function (result) {
            var strVar = "";
            for (var i in result.data) {
                if (i % 4 == 0) {
                    strVar += "<tr>";
                }
                if (i % 4 == 0) {
                    strVar += "<td><a href=\"javascript:void(0)\" onclick=\"subgo("+result.data[i].id+")\">"+result.data[i].charterName+"</a></td>";
                }
                if (i % 4 == 1) {
                    strVar += "<td><a href=\"javascript:void(0)\" onclick=\"subgo("+result.data[i].id+")\">"+result.data[i].charterName+"</a></td>";
                }
                if (i % 4 == 2) {
                    strVar += "<td><a href=\"javascript:void(0)\" onclick=\"subgo("+result.data[i].id+")\">"+result.data[i].charterName+"</a></td>";
                }
                if (i % 4 == 3) {
                    strVar += "<td><a href=\"javascript:void(0)\" onclick=\"subgo("+result.data[i].id+")\">"+result.data[i].charterName+"</a></td>";
                }
                if (i % 4 == 3) {
                    strVar += "<tr>";
                }
            }
            $("#table").append(strVar);
        });
    })
    function subgo(id) {
        window.location.href = "/context/" + id+"/-1";
    }
</script>
</body>
</html>